package Day02;

import java.lang.*;
public class Test04 {
    public static void main(String[] args) {
        //传闻StringBuilder比StringBuffer快,
        //比较一下，输出你的比较结果（拼接10万个相同的字符串，比较时间）。
        StringBuilder sb = new StringBuilder();
        long stat = System.nanoTime();
        for (int i = 0; i < 1000000000; i++) {
            sb.append(1);
        }
        long end = System.nanoTime();
        System.out.println("stringbur" + "需要" + (end - stat) + "的时间");

        StringBuffer s = new StringBuffer();
        long stat1 = System.nanoTime();
        for (int i = 0; i < 1000000000; i++) {
            s.append(1);
        }
        long end1 = System.nanoTime();
        System.out.println("StringBuffer" + "需要" + (end1 - stat1) + "的时间");


    }
}
